/*
 * @Author: szx
 * @Date: 2021-11-03 12:16:50
 * @LastEditTime: 2021-11-03 12:26:26
 * @Description:
 * @FilePath: \leetcode\1-99\83\83.cpp
 */
/*
 * @Author: szx
 * @Date: 2021-11-03 11:58:14
 * @LastEditTime: 2021-11-03 12:07:43
 * @Description:
 * @FilePath: \leetcode\200-299\206\206.cpp
 */
#include <iostream>
using namespace std;

struct ListNode {
    int val;
    ListNode* next;
    ListNode() : val(0), next(nullptr) {}
    ListNode(int x) : val(x), next(nullptr) {}
    ListNode(int x, ListNode* next) : val(x), next(next) {}
};

class Solution {
   public:
    ListNode* deleteDuplicates(ListNode* head) {
        if (!head) {
            return head;
        }
        ListNode* cur = head;
        while (cur->next) {
            if (cur->next->val == cur->val) {
                ListNode* tmp = cur->next;
                cur->next = cur->next->next;
                delete tmp;
            } else {
                cur = cur->next;
            }
        }
        return head;
    }
};

int main() { return 0; }